﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Net;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            
            MediaData a = new MediaData();

            //returns json as the only option
            #region moviedb testing
            Movie newMedia = a.getMovieById(76170);
            //a.getMovieListByGenreId(28, false, false);



            //List<Movie> movieList = a.getMovieListByGenreId(28, false, false);  //a.getGenreIdList();
            //movieList = movieList.OrderBy(x => x.Title).ToList();
            //foreach (Movie m in movieList) Console.WriteLine("*: " + m.Title);
            //Console.ReadLine();
            #endregion

            //return xml, as far as i can see, as the only option
            #region gamedb testing
/*
            Console.WriteLine("Start");
            List<VideoGame> list = a.getPlatformList("Sony Playstation 3");
            Console.WriteLine(list.Count);
            foreach (var game in list)
                Console.WriteLine(game.Title);
           
           // Console.WriteLine("\nExample of get platforms list:\n" + a.getPlatformList("Playstation 4"));
            Console.WriteLine("Slut");
            VideoGame vg = a.getGameByName("Sid Meier's Civilization V");

            Console.WriteLine(vg.Title + " " + vg.Publiser.Name + " " + vg.Studio.Name);

            foreach (var platform in vg.Platforms)
                Console.WriteLine(platform);

            foreach (var genre in vg.Genres)
                Console.WriteLine(genre);
*/
           // Console.WriteLine(a.getGameByName("Diablo"));
            /*
            Console.WriteLine("\n\nExample of get game by name:\n" + a.getGameByName("Halo"));

            Console.WriteLine("\nExample of get game by id:\n" + a.getGameById(5466));

            Console.WriteLine("\nExample of get platforms list:\n" + a.getPlatformList());

            Console.WriteLine("\nExample get games by platform:\n" + a.getGamesByPlatformId(4920)); //4920 is the id of the Xbox One
             */
            #endregion
            //returns either xml or json, xml looks more thorough
            #region bookdb testing
            /*List<Book> books = new List<Book>();
            books = a.GetBooksByGenre("fantasy");

            foreach (Book newBook in books)
            {
                Console.WriteLine("Title: " + newBook.Title);
                Console.Write("Authors: ");
                foreach (Author au in newBook.Author) Console.Write(au.Name + ", ");
                Console.Write("\nGenres: ");
                foreach (Genre ge in newBook.Genres) Console.Write("\n" + ge.ToString());
                Console.WriteLine();
            }
                /*
            Console.WriteLine("\n\nExample of get auther by name:\n" + a.GetBookByTitle("Cherie Priest"));
             */
            #endregion

            /*
            DbGateWay.StoreList<Book>(a.GetBooksByGenre("fantasy"));
            DbGateWay.StoreList<Book>(a.GetBooksByGenre("science_fiction"));
            DbGateWay.StoreList<Book>(a.GetBooksByGenre("crime"));

            DbGateWay.StoreList<Movie>(a.GetAllMovies());
            */
            DbGateWay.Store<Media>(a.getGameByName("Diablo"));
            List<VideoGame> list = new List<VideoGame>();
            DbGateWay.Retrieve<VideoGame>(out list, (x => x.Title == "Diablo"));
            foreach (VideoGame v in list) Console.WriteLine(v.Title);

            Console.WriteLine("***Done!***");
            Console.Read(); //dont know why it needs two reads, but it ignores it if theres only one
            Console.ReadLine();
        }
    }
}
